package com.baili.dao.call;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.baili.dao.base.BaseDao;
import com.baili.dto.ProductOrder;

/** 
 * @author iceX
 * @version 创建时间：2016年3月25日 上午10:07:01 
 * @Name: CallDaoImpl.java
 */ 
@Repository("CallDao")
public class CallDaoImpl extends BaseDao implements CallDao{
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
	
	@Override
	public List getCallTypeList(ProductOrder productOrder) {
		List<Object> list = this.sqlSessionTemplate.selectList("call.getCallTypeList",productOrder);
		return list;
	}

	@Override
	public List getCallYOrNHandle(ProductOrder productOrder) {
		return this.sqlSessionTemplate.selectList("call.getCallYOrNHandle",productOrder);
	}
	@Override
	public int getCount() {
		List<Object> list = this.sqlSessionTemplate.selectList("call.getCallTypeCount");
		int count = list.size();
		return count;
	}

	@Override
	public List getCallDealType(int dealType) {
		
		return this.sqlSessionTemplate.selectList("call.getDealTypeList",dealType);
	}

	@Override
	public List getCallDetails(int id) {
		
		return this.sqlSessionTemplate.selectList("call.getCallDetails", id);
	}

	@Override
	public List getCallTypeListByTime(String callTime, String overTime) {
		List<Object> list = new ArrayList<Object>();
		Map map = new HashMap();
		map.put("callTime", callTime);
		map.put("overTime", overTime);
		list = this.sqlSessionTemplate.selectList("call.getCallTypeListByTime", map);
		return list;
	}

	@Override
	public void isHandleCall(int id,String overTime,int userId) {
		
		Map map = new HashMap();
		map.put("id", id);
		map.put("overTime", overTime);
		map.put("userId", userId);
		
		this.sqlSessionTemplate.update("call.isHandleCall", map);
	}
	@Override
	public void deleteCallType(int callTypeId) {
		
		Map map = new HashMap();
		map.put("callTypeId", callTypeId);
		
		this.sqlSessionTemplate.delete("call.deleteCallType", map);
		
		this.sqlSessionTemplate.delete("call.deleteCallTypeById", map);
	}

}
